<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>toFixed的使用</title>
</head>

<body>
    <script>
        const num = 12.78
        console.log(num.toFixed()); // 13 默认保留整数，小数部分四舍五入
        console.log(num.toFixed(2)); // 12.78 保留两位小数
    </script>
</body>

</html>